package cst.a214frm.widgettest214frm;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private EditText inputtext;
    private Button textbutton,changebutton;
    private ImageView imageview;


    private void init(){
        inputtext=(EditText)findViewById(R.id.inputtext);
        textbutton=(Button)findViewById(R.id.textbutton);
        imageview=(ImageView)findViewById(R.id.imageView);
        changebutton=(Button)findViewById(R.id.changebuton);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        textbutton.setOnClickListener(this);
        changebutton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.textbutton:
                Toast.makeText(this, "内容是:"+inputtext.getText().toString(), Toast.LENGTH_SHORT).show();
                break;
            case R.id.changebuton:
                imageview.setImageResource(R.drawable.eclipse);
                imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);
                break;
        }
    }
}
